<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>

    <head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>注册</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.5 -->
		<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="css/AdminLTE.css">
		<!-- AdminLTE Skins. We have chosen the skin-blue for this starter
          page. However, you can choose any other skin. Make sure you
          apply the skin class to the body tag so the changes take effect.
    -->
		<!--<link rel="stylesheet" href="css/skins/skin-blue.min.css">-->
		<link rel="stylesheet" type="text/css" href="css/ant-login.css" />

		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
        <script src="//cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
        <script type="text/javascript"
	src="js/jquery-ui-1.11.4.custom/external/jquery/jquery.js"></script>
	<script type="text/javascript">
		  function fun(select){
		  	if(select.innerText=="lawerRegister")
		  	{
		  		document.getElementById("commonRegister").style.display = "none";
		  	}
		  }
</script>
	</head>

	<body>
		<div id="" class="container">
			<div class="row">
				<div class="col-md-12 text-center">
					<img src="img/logo2.png" />
				</div>
			</div>
		</div>
		
		<div id="commonRegister" class="container ant-regcontainer">
			<div class="row">
				<div class="col-xs-6 text-center" style="border-top: #C87F0A 2px solid;">
					<h3 class="color-y">注册</h3>
				</div>
				<div id="lawerRegister" class="col-xs-6 text-center opacity50" style="background: #C0C0C0;">
					<a href="registerJT.jsp"onclick='fun(this)'><h3 class="color-c">集团律师验证</h3></a>
				</div>
			</div>
			<div class="row" style="padding-top: 20px;">
				<div class="col-md-6 col-md-offset-3">
					<form action="" class="form-horizontal regForm" method="post">
						<div class="form-group">
							<div class="col-sm-12">
								<div class="text-center">
									<label>
										<h3> 快速注册 </h3>
									</label>
								</div>
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="userber" class="col-sm-3 control-label">用户名 *</label>
							<div class="col-sm-6">
								<!--<label class="icon-user"><i class="fa fa-user fa-2x"></i></label>-->
								<input type="text" id="username" name="username" class="form-control" placeholder="用户名" />
								<span class="glyphicon glyphicon-user form-control-feedback"></span>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="phonenumber" class="col-sm-3 control-label">手机号码 *</label>
							<div class="col-sm-6">
								<input type="tel" name="phonenumber" maxlength="11" id="phonenumber" class="form-control" placeholder="手机号码"  onkeydown="if(event.keyCode==13) {document.getElementById('getvertification').click();}"/>
								<span class="glyphicon glyphicon-phone form-control-feedback"></span>
							</div>
							<div class="col-sm-3">

							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="inputPassword3" class="col-sm-3 control-label">验证码 *</label>
							<div class="col-sm-3">
								<input type="text" class="form-control" maxlength="6" name="vertification" id="vertification" placeholder="验证码">
							</div>
							<div class="col-sm-3">
							<input type="button" class="btn btn-primary " value="获取验证码" id="getvertification" ></input>
						
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="phonenumber" class="col-sm-3 control-label">密码 *</label>
							<div class="col-sm-6">
								<input type="password" id="password" name="password" class="form-control" placeholder="3~16位数字或字母" onFocus="input_password()" onBlur="check_password()"  />
								<span class="glyphicon glyphicon-lock form-control-feedback"></span>
								<label id="tip"></label>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="password2" class="col-sm-3 control-label">确认密码 *</label>
							<div class="col-sm-6">
								<input type="password" id="password2" name="password2" class="form-control" placeholder="同密码一致" onBlur="check_password2()" />
								<span class="glyphicon glyphicon-lock form-control-feedback"></span>
								<label id="tip_password"></label>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="email" class="col-sm-3 control-label">Email *</label>
							<div class="col-sm-6">
								<input type="email" id="emial" name="emial" class="form-control" placeholder="电子邮箱地址" onBlur="check_emial()"/>
								<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
								<label id="tip_emial"></label>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12">
								<div class="text-center">
									<label>
										<h4> 以下为选填内容</h4>
									</label>
								</div>
							</div>
						</div>
						<div class="form-group has-feedback">
							<label for="phonenumber" class="col-sm-3 control-label">真实姓名 </label>
							<div class="col-sm-6">
								<!--<label class="icon-user"><i class="fa fa-user fa-2x"></i></label>-->
								<input type="text" id="lawyername" name="lawyername" class="form-control" placeholder="真实姓名" />
								<span class="glyphicon glyphicon-user form-control-feedback"></span>
							</div>
							<div class="col-sm-3">
							</div>
						</div>

						<div class="form-group">
							<label for="phonenumber" class="col-sm-3 control-label"> 执业证号 </label>
							<div class="col-sm-6 has-feedback">
								<input type="text" id="license" name="license" class="form-control" />
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group">
							<label for="phonenumber" class="col-sm-3 control-label"> 身份证号</label>
							<div class="col-sm-6">
								<input type="text" id="idnumber" name="idnumber" class="form-control" onBlur="check_idnumber()"/>
								<label id="tip_id"></label>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group">
							<label for="phonenumber" class="col-sm-3 control-label"> 执业区域 </label>
							<div class="col-sm-3">
								<select id="province" name="province" class="form-control">
									<option selected value="0">请选择省份</option>
									<option value="1">山东</option>
								</select>
							</div>
							<div class="col-sm-3">
								<select id="city" name="city" class="form-control">
									<option selected value="0">请选择城市</option>
									<option value="1">青岛</option>
								</select>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group">
							<label for="phonenumber" class="col-sm-3 control-label"> 执业律所 </label>
							<div class="col-sm-6">
								<select id="lawfirm" name="lawfirm" class="form-control">
									<option selected value="0">请选择办公律所</option>
									<option value="1">青岛德恒律师事务所</option>
								</select>
							</div>
							<div class="col-sm-3">
							</div>
						</div>

						<div class="form-group">
							<div class="col-sm-offset-3 col-sm-9">
								<div class="checkbox">
									<label>
										<p> 注册即代表同意《德恒用户注册协议》</p>
									</label>
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-3 col-sm-6">
								<font id="message" color="red"></font>
								<input type="button" class="btn btn-warning btn-block"  id="register"name="register"value="立即注册">
							</div>
							<div class="col-sm-3">

							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="hidden-xs">
			<div class="container" style="padding-top: 20px;">
				<a href="#" target="_blank">关于我们</a>|
				<a href="#" target="_blank">隐私条款</a>|
				<a href="#" target="_blank">社区规范</a>|
				<a href="#" target="_blank">用户反馈</a>|
				<a href="#" target="_blank">加入我们</a>|
				<a href="#" target="_blank">版权声明</a>
			</div>
		</div>
		<!--<nav class="  hidden-xs" style="  background: #2d3237;">
			<div class="container">
				<div class="row">
					<div class="col-md-6">
						<div class="row ant-footer">
							<div class="col-md-12" style="color: #fff;">
								<h3>
									InterLaw | <small>在线律师管理系统</small>            </h3>
							</div>
							<div class="col-md-12">
								<a href="#" target="_blank">关于我们</a>|
								<a href="#" target="_blank">隐私条款</a>|
								<a href="#" target="_blank">社区规范</a>|
								<a href="#" target="_blank">用户反馈</a>|
								<a href="#" target="_blank">加入我们</a>|
								<a href="#" target="_blank">版权声明</a>
								<br /> v
							</div>
						</div>
					</div>
					<div class="col-md-6">

					</div>

				</div>

			</div>
		</nav>-->
		<!--针对小屏幕显示-->
		<!--<div class="container visible-xs-inline-block">
			<div class="row">
				<div class="col-md-12">
					<a href="#" target="_blank">关于我们</a>|
					<a href="#" target="_blank">隐私条款</a>|
					<a href="#" target="_blank">社区规范</a>|
					<a href="#" target="_blank">用户反馈</a>|
					<a href="#" target="_blank">加入我们</a>|
					<a href="#" target="_blank">版权声明</a>
				</div>
			</div>
		</div>-->
		<!--针对小屏幕显示结束-->

		<!--<script src="jQuery/jQuery-2.1.4.min.js"></script>-->
		<script src="jQuery/jquery-1.11.2.min.js" type="text/javascript"></script>
		<!-- Bootstrap 3.3.5 -->
		<script src="bootstrap/js/bootstrap.min.js"></script>
		<!--<script type="text/javascript" src="js/login.js"></script>-->
		<script src="js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript"></script>
		 <script>
  var phonenumber="";   //手机号
  var vertification="";  //用户输入的验证码
  var password="";
  var password2="";
  var emial="";
  var lawyername="";
  var license="";
  var idnumber="";
  var lawfirm="";
  var province="";
  var city="";
  //发送验证码时添加cookie
function addCookie(name,value,expiresHours){ 
    var cookieString=name+"="+escape(value); //获取剩余的秒数
    //判断是否设置过期时间,0代表关闭浏览器时失效
    if(expiresHours>0){ 
        var date=new Date(); 
        date.setTime(date.getTime()+expiresHours*1000); 
        cookieString=cookieString+";expires=" + date.toUTCString(); 
    } 
     	//alert("add cookieString "+cookieString);
        document.cookie=cookieString; 
} 
//修改cookie的值
function editCookie(name,value,expiresHours){ 
    var cookieString=name+"="+escape(value); 
    if(expiresHours>0){ 
      var date=new Date(); 
      date.setTime(date.getTime()+expiresHours*1000); //单位是毫秒
      cookieString=cookieString+";expires=" + date.toGMTString(); 
    } 
      document.cookie=cookieString; 
} 
//根据名字获取cookie的值
function getCookieValue(name){ 
      var strCookie=document.cookie; //getcookie
     // alert("get strCookie  "+strCookie)
      //var arrCookie=strCookie.split("="); //"="
//将多cookie切割为多个名/值对 
var arrCookie=strCookie.split("; "); 
//遍历cookie数组，处理每个cookie对 
for(var i=0;i<arrCookie.length;i++){ 
var arr=arrCookie[i].split("="); 
//找到名称为userId的cookie，并返回它的值 
if(name==arr[0]){ 
//alert(arr[1]);
return arr[1];
} 
}
return "undefined"; 
}

//发送验证码
function sendCode(){
 $.ajax({
type: "POST",
url:"vertify.action",	//把表单数据发送到ajax.jsp
dataType: "json", 	//返回数据类型
data:{
"phonenumber":phonenumber.value
},
async: true,
error: function(request) {
$("#message").text("发送请求失败！");
},
success: function(data) {
var json = eval("(" + data + ")"); 
if(json.respCode=="105122"){
//alert("验证码发送次数超限，请明天再试");
$("#message").text("验证码发送次数超限，请明天再试");
//addCookie("secondsremained",60,60);//添加cookie记录,有效时间60s
//settime($("#getvertification"));//开始倒计时
}
else{
//alert("如果长时间未收到短信，请重新点击获取验证码");
$("#message").text("如果长时间未收到短信，请重新点击获取验证码");
addCookie("secondsremained",60,60);//添加cookie记录,有效时间60s
settime($("#getvertification"));//开始倒计时应添加到上述else中，仅为调试方便
}
}
});

}
//开始倒计时
var countdown;
var t;
function settime(obj) { 
    countdown=getCookieValue("secondsremained");
 //   alert("countdown"+countdown);
    if (countdown == "1") { 
        obj.removeAttr('disabled');    
        obj.val("获取验证码");  
        clearInterval(t);
        return;
    } else { 
        obj.attr('disabled', true); 
        obj.val("重新发送(" + countdown + ")"); 
        countdown--;
        editCookie("secondsremained",countdown,countdown+1);
    } 
    t=setTimeout(function() { settime(obj) },1000) //每1000毫秒执行一次       
} 
  onload=function()
{
 phonenumber = document.getElementById("phonenumber");//js形式获得bieshehuile````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````			```````
 vertification = document.getElementById("vertification"); 
 password = document.getElementById("password"); 
 password2 = document.getElementById("password2"); 
 emial = document.getElementById("emial");   
 lawyername = document.getElementById("lawyername");   
 license = document.getElementById("license");   
 idnumber = document.getElementById("idnumber"); 
 lawfirm  = document.getElementById("lawfirm"); 
 province  = document.getElementById("province"); 
 city = document.getElementById("city"); 
 tip = document.getElementById("tip"); 
 tip_password = document.getElementById("tip_password"); 
 tip_id = document.getElementById("tip_id"); 
 tip_emial = document.getElementById("tip_emial"); 
}
 function input_password(){
$("#tip").text("密码为3-16位的数字或字母");
}
function check_password(){
	var myreg = /^[a-zA-Z0-9_]{3,16}$/; //正则表达式 3-16
	if(!myreg.test(document.getElementById("password").value)) //不匹配的情况
	{
		$("#tip").text("密码格式错误,必须为3-16位的数字或字母");	
	} 
	else $("#tip").text("");
}
function check_password2(){
	if(document.getElementById("password").value!=document.getElementById("password2").value) //不匹配的情况
	{
		$("#tip_password").text("两次密码输入不一致");
	} 
	else $("#tip_password").text("");
}
check_idnumber = function(){
 if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(document.getElementById("idnumber").value)))
   {
      $("#tip_id").text("身份证输入有误");     
	}
	else $("#tip_id").text("");
}
check_emial = function(){
 if (!(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(document.getElementById("emial").value)))
   {
      $("#tip_emial").text("邮箱输入有误");     
	}
	else $("#tip_emial").text("");
}
function check()
{
	if(tip.innerHTML!=null&&tip.innerHTML!=""){
	//alert("密码输入有误,请检查");
	$("#message").text("密码输入有误,请检查");
	return false;
	}
	else if(tip_password.innerHTML!=null&&tip_password.innerHTML!=""){
	//alert("两次密码输入不一致");
	$("#message").text("两次密码输入不一致");
	return false;
	}
	else if(tip_id.innerHTML!=null&&tip_id.innerHTML!="")
	{
	//alert("身份证输入有误");
	$("#message").text("身份证输入有误");
	return false;
	}
	else if(tip_emial.innerHTML!=null&&tip_emial.innerHTML!="")
	{
	//alert("邮箱输入有误");
	$("#message").text("邮箱输入有误");
	return false;
	}
	return true;
}
        $(document).ready(function(){  //页面加载完成即执行
        $("#getvertification").click(function(){//获取验证码响应JQuery
         phonenumber = document.getElementById("phonenumber");//加载phonenumber
         //检验手机号是否违法
        var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; //正则表达式
		if(!myreg.test(phonenumber.value)) //不匹配的情况
		{ 
		  	// alert("请输入有效的手机号码！"); 
		  	 $("#message").text("请输入有效的手机号码！");
		   	return false; 
		} 
         sendCode(); // ajax发送数据
         
});     //验证按钮响应        
        $("#register").click(function(){//
         onload();		//加载函数
    		if(check()){   //检查各个必填项，以及已经填写的选填项格式
    		alert($("input[name='vertification']").val());
         $.ajax({  //提交ajax数据
type: "POST",
url:"register.action",	//把表单数据发送到ajax.jsp
dataType: "json", 
data:{
"vertification":$("input[name='vertification']").val(),//JQuery形式
"phonenumber":phonenumber.value,
"password":password.value,
"emial":emial.value,
"lawyername":lawyername.value,
"license":license.value,
"idnumber":idnumber.value,
"lawfirm":lawfirm.value,
"province":province.value,
"city":city.value
},
async: true,
error: function(request) {
//alert("发送请求失败！");
 $("#message").text("发送请求失败！");
},
success: function(data) {

var json = eval("(" + data + ")"); //获得json数据返回
if(json.code=="true"){ //判断是否验证成功
self.location='login.jsp';
}
else if(json.code=="exist"){
	//alert("手机号已经使用,请更换手机号以作为用户名");//验证错误
	 $("#message").text("手机号已经使用,请更换手机号以作为用户名");
}else{
	//alert("验证码错误，请重新输入");//验证错误
	 $("#message").text("验证码错误，请重新输入");
}
}
});  
}     
});   
//用于上次计时未结束时
var v = getCookieValue("secondsremained");//获取cookie值
if(v!="undefined"&&v!="NaN"){    // ==undefined/NaN 刚开始时候
//alert("tosettime "+v);
settime($("#getvertification"));//上次刷新之前处于倒计时状态，则继续倒计时
}
});   
  </script >
	</body>

</html>